#include <stdio.h>

void _increment(int n){
	n = n+1;
}


void _incrementByPointer(int *n){
	*n = *n+1;
}

// void incrementByAddress(int &n){
// 	n = n+1;
// }

int main(void){
	/* 指针的一些使用
	int na = 0;
	int *nb = (int *)malloc(sizeof(int));
	*nb= 0;
	int nc = 0;

	_increment(na);
	printf("increment = %d\n", na);

	_incrementByPointer(nb);
	printf("incrementByPointer = %d\n", *nb);
	free(nb);

	_incrementByPointer(&nc);
	printf("incrementByAddress = %d\n", nc);
	*/

	int number = 0;				//A variable of type int initialized to 0
	int *pnumber = NULL;		//A pointer that can point to type int

	number = 10;
	printf("number's address: %p\n", &number);		//Output the address
	printf("number's value: %d\n", number);			//Output the value

	pnumber = &number;			//Store the address of number in pnumber

	printf("pnumber's address:%p\n", (void*)&pnumber); 		//Output the address  
	printf("pnumber's size: %zd bytes\n", sizeof(pnumber));	//Output the size
	printf("pnumber's value: %p\n",pnumber);				//Output the value(an address)
	printf("value pointed to: %d\n", *pnumber);				//Value at the address
	/**Output:
	number's address: 0x7fffd695971c
	number's value: 10
	pnumber's address:0x7fffd6959710
	pnumber's size: 8 bytes
	pnumber's value: 0x7fffd695971c
	value pointed to: 10

	*/



	return 0;
}


